package org.dftproject.genesis.ui.pages.circlediagram;

import org.dftproject.genesis.data.genealogy.GenealogyConstants;
import org.dftproject.genesis.data.genealogy.GenealogyUtils;
import org.dftproject.genesis.data.genealogy.IName;
import org.dftproject.genesis.data.genealogy.IPerson;
import org.dftproject.genesis.data.genealogy.Sex;
import org.dftproject.genesis.ui.SharedImages;
import org.dftproject.genesis.ui.pages.AbstractPageInput;

public class CircleDiagramPageInput extends AbstractPageInput {
	
	private IPerson person;
	
	public CircleDiagramPageInput(IPerson person) {
		setPerson(person);
	}

	public IPerson getPerson() {
		return person;
	}

	public void setPerson(IPerson person) {
		this.person = person;

		IName name = (IName) GenealogyUtils.getValue(person, GenealogyConstants.name, IName.class);
		if (name != null)
			setLabel(GenealogyUtils.stringFromName(name));
		else
			setLabel("(Unknown)");
		
		Sex sex = (Sex) GenealogyUtils.getValue(person, GenealogyConstants.sex, Sex.class);
		if (sex == Sex.Male)
			setImageDescriptor(SharedImages.getDefault().getImageDescriptor(SharedImages.IMG_MALE));
		else if (sex == Sex.Female)
			setImageDescriptor(SharedImages.getDefault().getImageDescriptor(SharedImages.IMG_FEMALE));
	}
	
}
